package list.test;

/**
 * @author PC
 * @date 2020/5/18
 * 深拷贝
 */
public class Person implements Cloneable{
    private String name;
    private Integer age;
    private Skill skill;

    public Person() {
    }

    @Override
    public Object clone() throws CloneNotSupportedException {
        Person stu = (Person) super.clone();
        Skill skill = (Skill) this.skill.clone();
        stu.setSkill(skill);
        return stu;
    }

    public Person(String name, Integer age, Skill skill) {
        this.name = name;
        this.age = age;
        this.skill = skill;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Skill getSkill() {
        return skill;
    }

    public void setSkill(Skill skill) {
        this.skill = skill;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", skill=" + skill +
                '}';
    }
}
